package chap6;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Scoreavg5 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //求平均分，碰到负数，终止录入,结束程序
        double sum = 0;

        for (int i = 1; i <= 6; i++) {
            System.out.print("请输入第" + i + "门课的成绩：");
            double s = sc.nextDouble();
            if (s < 0) {
                System.out.println("成绩录入错误，不能小于0，无法计算");
                return;
            }
            sum = sum + s;
        }

        double avg = sum / 6;
        //留一个小数点
        System.out.println(avg);
        System.out.println("平均分是:" + ((int) (avg * 10) / 10.0));

    }
}
